package core.domain;

import core.enums.ResultCode;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
@Data
public class ListDataInfo {
    private Integer total;

    private List<?> rows;

    private int code;

    private String message;

    private Integer currentPage;
    public static ListDataInfo empty(){
        ListDataInfo listDataInfo = new ListDataInfo();
        listDataInfo.setRows(new ArrayList<>());
        listDataInfo.setCode(ResultCode.SUCCESS.getCode());
        listDataInfo.setMessage(ResultCode.SUCCESS.getMessage());
        listDataInfo.setTotal(0);
        return listDataInfo;
    }

    public static ListDataInfo success(List<?> list, int total){
        ListDataInfo listDataInfo = new ListDataInfo();
        listDataInfo.setRows(list);
        listDataInfo.setCode(ResultCode.SUCCESS.getCode());
        listDataInfo.setMessage(ResultCode.SUCCESS.getMessage());
        listDataInfo.setTotal(total);
        return listDataInfo;
    }

}
